import request from '@/utils/request'

const home = {
    state: {
        statisticalData: {
            memberTotalCount: 0,
            prePaymentOrderCount: 0,
            preReceiveOrderCount: 0,
            preShipOrderCount: 0,
            refundOrderCount: 0,
            returnApplyOrderCount: 0,
            shippedOrderCount: 0,
            thisMonthNewMemberCount: 0,
            todayNewMemberCount: 0,
            todayOrderCount: 0,
            todaySellTotalAmount: 0,
            withdrawCount: 0,
            yesterdayNewMemberCount: 0,
            yesterdaySellTotalAmount: 0,
            //   opened: !+Cookies.get('sidebarStatus'),
            //   withoutAnimation: false
        },
        device: 'desktop'
    },
    mutations: {
        UPDATE_HOMEDATA: (state, data) => {
            console.log('state', state);
            console.log(data)
            state.statisticalData = data;
            // state.sidebar.opened = !state.sidebar.opened
        },
    },
    actions: {
        update_homeData: ({ commit }, data) => {
            console.log(14111111)
            return new Promise((resolve, reject) => {
                request({
                    url: 'home/statisticalData',
                    method: 'post',
                    data: {}
                  }).then(resp => {
                    commit('UPDATE_HOMEDATA', resp.info)
                    resolve(data)
                }).catch(error => {
                    console.log(error)
                    reject(error)
                });
                // request.post("/product/comments", data).then(data => {
                // 	commit('SET_COMMENT', data)
                // 	resolve(data)
                // }).catch(error => {
                // 	reject(error)
                // })
            })

            // commit('UPDATE_HOMEDATA', data)
        }
    }
}

export default home
